
    <!DOCTYPE html>
<html class="no-js " lang="zh-CN" >
<script type="text/javascript">
    window.l_createElement = document.createElement;
    window.l_Function = window.Function;
    window.l_open = window.open;
    window.l_adoptNode = document.adoptNode;
    window.l_defineProperty = Object.defineProperty;
</script>
<head>
    <meta charset="utf-8">
    <meta name="keywords" content="口袋通,微信商城,粉丝营销,微信商城运营" />
    <meta name="description" content="口袋通是帮助商家在微信上搭建微信商城的平台，提供店铺、商品、订单、物流、消息和客户的管理模块，同时还提供丰富的营销应用和活动插件。" />
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="cleartype" content="on">
    <!-- dns prefetch -->
    <link rel="dns-prefetch" href="//tj.bidcms.com/" />
    <link rel="dns-prefetch" href="//imgqn.bidcms.com/" />
    <link rel="dns-prefetch" href="//kdt-static.qiniudn.com/" />

    <link rel="icon" href="${webRoot}/static/v2/image/favicon.ico" />
    <title>设置新密码</title>
    <!-- _global -->
    <script>

	document.createElement = window.l_createElement;
	window.Function = window.l_Function;
	window.open = window.l_open;
	document.adoptNode = window.l_adoptNode;
	Object.defineProperty = window.l_defineProperty;

    var _global = {"kdt_id":0,"user_id":0,"run_mode":"online","debug":false,"project":"default","online_debug":true,"js":{"js_compress":true,"css_compress":true,"use_js_cdn":true,"use_css_cdn":true,"message_report":true,"checkbrowser":true,"hide_wx_nav":true,"qn_public":"kdt_img","qn_private":"kdt-private"},"query_path":"\/buyer\/auth\/login","real_query_path":"get:\/buyer\/auth\/login.html","module":"buyer","controller":"Buyer_Auth_Controller","action":"login","full_action":"getLoginHtml","method":"get","format":"html","platform":"unknown","is_mobile":false,"page_size":320,"isShopDomain":false,"share":{"title":"","desc":"","cover":"","link":""},"source":"","track":"","verify_fans_merge":"","nobody":"545b7fa855dd4","no_sidebar":1};
	_global.url=''${global.url}'';
	_global.share.link=_global.url.wap+'/index.php?con=buyer&act=usercenter&alias=9zr1r4l1';
	_global.redirect_url=_global.url.wap+'/index.php?con=buyer&act=usercenter&alias=9zr1r4l1';
	_global.logURL=_global.url.base+'/static/v2/image/1.gif';
    //base_head_script.js
    function viewportMeta(){var e=parseInt(window.screen.width),t=e/640,i=navigator.userAgent;if(/Android (\d+\.\d+)/.test(i)){var a=parseFloat(RegExp.$1);document.write(a>2.3?'<meta name="viewport" content="width=640, minimum-scale = '+t+", maximum-scale = "+t+', target-densitydpi=device-dpi">':'<meta name="viewport" content="width=640, target-densitydpi=device-dpi">')}else document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">')}function _cdnFallback(e){var t=e.nodeName.toLowerCase(),i=document.createElement(t),a={script:"src",link:"href"},n=a[t],o=e[n];o=o.replace("kdt-static.qiniudn.com","kdt-static.b0.upaiyun.com"),"link"==t&&(i.rel="stylesheet"),i[n]=o,document.body.appendChild(i)}!function(e){var t=document.documentElement;e.match(/micromessenger\/5/gi)?t.className=t.className+" mobile wx_mobile wx_mobile_5":e.match(/micromessenger/gi)?t.className=t.className+" mobile wx_mobile":window._global.is_mobile&&(t.className=t.className+" mobile")}(navigator.userAgent||navigator.vendor||window.opera);
</script>


    <!-- meta viewport -->
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    
    <!-- CSS -->
    <link rel="stylesheet" href="${webRoot}/static/v2/build_css/stylesheets/wap/base.css" >    <link rel="stylesheet" href="${webRoot}/static/v2/build_css/stylesheets/wap/projects/buyer.css" >        </head>

<body class=" ">
        <!-- container -->
    <div class="container js-modal-login">
                <div class="account-form">
    <form class="js-change-password-form" method="GET" action="http://wap.bidcms.com/v2/buyer/auth/login.jsonp">
        <h2 class="form-title big">
            <span>设置新密码</span>
        </h2>
        <ul class="block block-form margin-bottom-normal">
            <li class="block-item">
                <label>手机号码</label>
                                <input type="tel" name="phone" maxlength="11" class="js-txt-telphone" autocomplete="off" placeholder="请输入您的手机号" value=""/>
            </li>
            <li class="block-item">
                <label>新密码</label>
                <input type="password" name="password" autocomplete="off" maxlength="20" class="js-txt-password" placeholder="请设置您的新密码" />
            </li>
            <li class="relative block-item">
                <label>验证码</label>
                <input type="tel" name="code" class="js-txt-auth" placeholder="请输入短信验证码" maxlength="6"/>
                <button type="button" class="btn btn-green btn-auth-code font-size-12 js-send-auth" data-text="获取验证码">
                    获取验证码
                </button>
            </li>
        </ul>
        <div class="action-container">
            <button type="submit" class="btn btn-green btn-block">确认提交</button>
            <button type="button" class="js-login-cancel btn btn-block btn-white" >返回</button>
        </div>
    </form>
</div>                    </div>

    <!-- JS -->
    <script src="${webRoot}/static/v2/vendor/jquery-2.0.3.min.js" ></script>
    <script src="${webRoot}/static/v2/build/wap/base.js" ></script>
    
    <script>
var timer;
function btnCountdown(obj, second, callback) {
    $(obj).text(second + '秒');
    if (--second >= 0) {
        timer = setTimeout(function() {
            btnCountdown(obj, second, callback);
        }, 1000);
    } else {
        callback();
    }
}

var sendBtn = $('.js-send-auth'),
    txtPhone = $('.js-txt-telphone'),
    txtPwd = $('.js-txt-password'),
    txtAuth = $('.js-txt-auth'),
    backBtn = $('.js-login-cancel');

sendBtn.on('click', function(event) {
    event.preventDefault();

    // txtAuth.attr('placeholder', '');
    var _phone = $.trim(txtPhone.val());
    getAuthCode(_phone);

});

backBtn.click(function() {
    event.preventDefault();
    window.history.back();

});

function stopTimer() {
    clearTimeout(timer);
    sendBtn.prop('disabled', false);
    sendBtn.text('点此获取');
}

function startTimer() {
    sendBtn.prop('disabled', true);
    btnCountdown(sendBtn, 60, function() {
        sendBtn.text('再次获取');
        sendBtn.prop('disabled', false);
        txtAuth.attr('placeholder', '没有收到验证码？');
    });
}

function getAuthCode(phone) {

    if (!phone) {
        motify.log('请先填写您的手机号码');
        txtPhone.focus();
        return false;
    }

    var _url = window._global.url.wap + '/buyer/auth/verifycode.php';
    $.ajax({
        url: _url,
        type: 'GET',
        dataType: 'json',
        data: {
            phone: phone
        },
        beforeSend: function() {
            startTimer();
        },
        success: function(resp) {
            if (resp.code === 0) {

            } else {
                stopTimer();
                motify.log(resp.msg);
            }
        },
        error: function(xhr, errorType, error) {
            stopTimer();
            motify.log('获取验证码失败，请稍后再试');
        },
        complete: function(xhr, status) {},
    });

}

var pwdform = $('.js-change-password-form');
pwdform.on('submit', function(event) {
    event.preventDefault();

    var postData = $.kdt.getFormData(pwdform);
    postData = fixFormData(postData);

    if (validForm(postData)) {
        changPassword(postData);
    }
});

function fixFormData(postData) {
    console.error(JSON.stringify(postData));

    $.each(postData, function(key, value) {
        console.error(value)
        console.error(key)
        postData[key] = $.trim(value);
    });

    console.error(JSON.stringify(postData));
    return postData;
}

function validForm(postData) {
    if (!postData.phone) {
        motify.log('请先填写您的手机号码');
        txtPhone.focus();
        return false;
    }
    if (!(/^1\d{10}$/).test(postData.phone)) {
        motify.log('请填写11位手机号码');
        txtPhone.focus();
        return false;
    }

    if (!postData.password) {
        motify.log('麻烦输入一下您的新密码吧');
        txtPwd.focus();
        return false;
    }
    if (!postData.code) {
        motify.log('请先填写您的短信验证码');
        txtAuth.focus();
        return false;
    }
    return true;
}


function changPassword(postData) {
    var _url = window._global.url.wap + '/buyer/auth/changepassword.php';
    $.ajax({
        url: _url,
        type: 'POST',
        dataType: 'json',
        data: postData,
        beforeSend: function() {
        },
        success: function(resp) {
            if (resp.code === 0) {
                motify.log('修改密码成功', 0);
                var redirect = window._global.redirect_url;
                if (redirect) {
                    if(-1 === redirect.indexOf('?')){
                        redirect += '?';
                    }else{
                        redirect += '&';
                    }
                    redirect += 'phone=' + postData['phone'];
                    window.location.href = redirect;
                }
            } else {
                motify.log(resp.msg);
            }
        },
        error: function(xhr, errorType, error) {
            stopTimer();
            motify.log('获取验证码失败，请稍后再试');
        },
        complete: function(xhr, status) {},
    });
}

</script>    
    </body>
</html>